#include "Assignment.h"


Assignment::Assignment(Assignable *_id, Expr *_expr, int _ln)
    :id(_id), expr(_expr), Stmt(_ln)
{
}


Assignment::~Assignment(void)
{
    delete expr;
    delete id;
}

int Assignment::Eval()
{
    int nVal = expr->EvalInt();
    float fVal = expr->EvalFlt();

    if (id->Type() == INT)
    {
        id->SetValue(nVal);
    }
    else if (id->Type() == FLT)
    {
        id->SetValue(fVal);
    }

    return -1;
}


